﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace RemoteEP
{
    [ServiceContract(Name = "IEAIEndpointService")]
    public interface IEAIEndpointService
    {
        [OperationContract]
        string Ping();

        [OperationContract]
        TransactionItemsComposite Submit(TransactionItemsComposite TransferredContent);
    }

    [DataContract]
    public class TransactionItemsComposite
    {
        [DataMember]
        public List<DataPayload> myPayload; //Collection of files being submitted
        [DataMember]
        public string InterfaceID; // Interface Identifier to identify the appropriate interface for parsing and despatching

        [DataMember]
        public string ContentIdentifier; //Content Identifier or Mail Subject Line, May be same as Interface Identifier, but not always.

        [DataMember]
        public string BodyText; //Body Text of email or scripting content.

        [DataMember]
        public string CallingSystemId; //Identity of the application or service calling the gateway

        [DataMember]
        public string ItemReceiptReferenceCode; //Calling system reference id for transaction Item

        [DataMember]
        public string SenderIdent; //Identity of the user logged in or mail sender that raised the transaction.
        [DataMember]
        public string ProcessingPath; // Interim Path for processing of files, should be cleared prior to use to avoid incomplete transactions.
        [DataMember]
        public string FinalDestinationPath; //Folderpath destination of all submitted files in payload, should go through a processing path first;
        [DataMember]
        public string RecipientSpecificRoutingInfo; //Collection of Mail Addresses or other Recipient Specific Data

        [DataMember]
        public string UserIDForThirdParty;// (Used by Service Level for access to 3rd party system such as FTP or Webservice)
        [DataMember]
        public string PasswordForThirdParty;// (Used by Service Level for access to 3rd party system such as FTP or Webservice)
        [DataMember]
        public string NotificationMailAddress; //(Could be used at processing level or service level to provide feedback on the current processing stage)
        [DataMember]
        public string FtpAddress; //Address for use to determine URI of FTP and SFTP systems
        [DataMember]
        public int PortNumber; //(Port Number might be used where additional info is required for sending via remote FTP)
        [DataMember]
        public string DeliveryAddress;// (This would be used to append an additional delivery email address for use at service level)
        [DataMember]
        public string AdditionalContent;// Inclusion of additional content for scripting or other purposes defined at interface level for use by service
        [DataMember]
        public bool RTNInsertIncludedTransactionItems;//Specifies that the contents must be inserted on the next processing iteration level, must be true if payload is to be added to database.
        [DataMember]
        public int IterationLevel;//The iteration level on which the files are being processed by the processing agent on the core system, may or may not be relevant for events outside of processing.
        [DataMember]
        public bool OverwriteifExists;//Specifies whether the file is overwritten, if not set then a new file will be created using incrementing integer.
        public class DataPayload //file payload structure
        {
            public byte[] fileArray;
            public string fileName;
        }
    }
}
